﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Data;

namespace Project
{
    public class ClassGet_ID
    {
        string strConnString = WebConfigurationManager.ConnectionStrings["DB_UdrinkConnectionString"].ConnectionString;

         public int GetIDStock()
        {
            int id;
            string sqltext = @"SELECT ISNULL (MAX(NO),0)
                                from TB_Stock";
            SqlCommand sqlcomm = new SqlCommand();
            SqlConnection sqlconn = new SqlConnection(strConnString);
            sqlcomm.Connection = sqlconn;
            sqlcomm.CommandType = System.Data.CommandType.Text;
            sqlcomm.CommandText = sqltext;
            try
            {
                sqlcomm.Connection.Open();
                id = (int)sqlcomm.ExecuteScalar() + 1;
            }
            catch (Exception)
            {

                sqlcomm.Connection.Close();
                sqlcomm.Connection.Dispose();
                throw;
            }
            sqlcomm.Connection.Close();
            sqlcomm.Connection.Dispose();
            return id;
        }
         public DataTable GetIDEmp()     
         {
             string sqltext = @"SELECT*FROM TB_Employee;";
             SqlConnection sqlconn = new SqlConnection(strConnString);
             SqlDataAdapter da = new SqlDataAdapter(sqltext, sqlconn);
             DataSet ds = new DataSet();
             da.Fill(ds);
             return ds.Tables[0];

         }
       //dsddddd
    }
}